package com.ziyun.erp.modules.report.service.impl;

import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.ziyun.erp.common.e.erpReport.SelfShopEnum;
import com.ziyun.erp.common.e.goods.GoodsTypeEnum;
import com.ziyun.erp.common.utils.JsonUtils;
import com.ziyun.erp.modules.report.dao.ReportStoreProductPriceDao;
import com.ziyun.erp.modules.report.entity.ReportStoreProductPriceEntity;
import com.ziyun.erp.modules.report.entity.ReportStoreProductPriceVO;
import com.ziyun.erp.modules.report.service.ReportStoreProductPriceService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


@Service("reportStoreProductPriceService")
public class StoreProductPriceServiceImpl extends ServiceImpl<ReportStoreProductPriceDao, ReportStoreProductPriceEntity> implements ReportStoreProductPriceService {
    @Autowired
    private ReportStoreProductPriceDao reportStoreProductPriceDao;

    @Override
    public R list(Map<String, Object> params) {
        Page<ReportStoreProductPriceVO> page = new Page<>();
        page.setCurrent(Integer.valueOf(params.get("page").toString()));
        page.setSize(Integer.valueOf(params.get("limit").toString()));
        List<ReportStoreProductPriceVO> list = reportStoreProductPriceDao.list(page, params);
        page.setRecords(list);
        PageUtils pageUtils = new PageUtils(page);
        // 存放枚举类到userdata
        Map<String, Object> mapEnum = new HashMap<>();
        mapEnum.put("selfShopEnum", JsonUtils.enumToList(SelfShopEnum.class)); //门店列表
        mapEnum.put("goodsTypeEnum", JsonUtils.enumToList(GoodsTypeEnum.class)); //商品类型

        return R.ok().put("page", pageUtils).put("userData", mapEnum);
    }

}
